#include<boost/asio.hpp>
#include<iostream>
#include<unistd.h>
namespace asio = boost::asio;
using tcp=asio::ip::tcp;
int main(int argc, char const *argv[])
{
    try{
    asio::io_context io;
    tcp::acceptor acceptor(io,tcp::endpoint(tcp::v4(),8000));
    acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
    acceptor.listen();
    auto socket=acceptor.accept();
    while (true)
    {
        std::string str;
        str.resize(100);//注意分配大小
        socket.receive(asio::buffer(str));
        socket.send(asio::buffer(str));
    }
    io.run();
    } catch (boost::system::system_error e)
    {
        std::cout<<e.what()<<std::endl;
    }   
}
